{layout name="common/layout" /}
<section class="panel">
    <header class="panel-heading">
        添加会员
    </header>
    <div class="panel-body">
        <form class="form-horizontal" id="member_form">
            <div class="form-group">
                <label  class="col-lg-2 col-sm-2 control-label">用户昵称</label>
                <div class="col-lg-10">
                    <input type="text" name="member_name" class="form-control" value="" >
                    <p class="help-block">如:拼图云商城</p>
                </div>
            </div>
            <div class="form-group">
                <label  class="col-lg-2 col-sm-2 control-label">用户帐号(手机号)</label>
                <div class="col-lg-10">
                    <input type="tel" name="member_mobile" class="form-control" value="" >
                    <p class="help-block">如:185***1235</p>
                </div>
            </div>
            <div class="form-group">
                <label  class="col-lg-2 col-sm-2 control-label">用户真实姓名</label>
                <div class="col-lg-10">
                    <input type="text" name="member_truename" class="form-control" value="" >
                    <p class="help-block">如:王**</p>
                </div>
            </div>
            <div class="form-group">
                <label  class="col-lg-2 col-sm-2 control-label">用户头像</label>
                {:tplSingleImage('headimg')}
                <div class="row"></div>
                <div class="col-lg-5 col-lg-offset-2">建议尺寸(70*70)</div>
            </div>

            <div class="form-group">
                <div class="col-lg-offset-2 col-lg-10">
                    <button type="submit" class="btn btn-primary">保存</button>
                </div>
            </div>
        </form>
    </div>

</section>
<script type="text/javascript">
    $('#member_form').submit(function () {
        var member_name = $('input[name="member_name"]').val();
        if(!member_name){
            toastTop('用户昵称不能为空',2);
            return false;
        }
        var headimg = $('input[name="headimg"]').val();
        if(!headimg){
            toastTop('用户头像不能为空',2);
            return false;
        }
        var tel = $('input[name="member_mobile"]').val();
        if(!isPhone(tel)){
            toastTop('手机格式不正确',2);
            return false;
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:'{:WebUrl('adminmember/add')}',
            data:$('#member_form').serialize(),// 你的formid
            async: false,
            error: function(data) {
                toastTop('服务器错误，稍后再试',2);
            },
            success: function(data) {
                if(data.status=1){
                    toastTop('添加成功');
                    setTimeout(function(){
                        window.location='{:WebUrl('adminmember/index')}';
                    },600)
                }else{
                    toastTop('添加失败');
                }
            }
        },'json');
        return false;
    });


</script>